package org.zlm.git_study.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zlm.git_study.annotation.AccessLimit;
import org.zlm.git_study.pojo.User;
import org.zlm.git_study.util.I18nUtil;
import org.zlm.git_study.util.MessageUtils;

import javax.servlet.http.HttpServletRequest;

/**
 * @author zlm
 * @date 2023/12/16
 */
@RestController
@RequiredArgsConstructor
public class MessageController {

    private final HttpServletRequest request;
    @RequestMapping("/message")
    public String message() {
        System.out.println(MessageUtils.get("validator.error_message.not_null"));
        String msg = I18nUtil.getMessage("validator.error_message.not_null", request.getHeader("lang"));
        System.out.println(msg);
        return msg;
    }

    @AccessLimit
    @RequestMapping("/save")
    public String save(User users) {
        return users.toString();
    }
}
